<template>
	<view>
		<cover-view class='fu-iconfont2  platformMessage_fd0_0_c0_c0' @click="back">&#xE794;</cover-view>
		<video id="videoId" v-if="videoplay" object-fit="contain" :initial-time="initTime" :src="videoUrl" autoplay :show-fullscreen-btn="false" @pause="videoPause" @ended="videoEnd" @error="videoError" @timeupdate="timeupdate"></video>
	</view>
	
</template>
<script>
	export default {
		components: {},
		data() {
			return {
				videoplay: false,
				videoUrl: "",
				videoTime: 0,
				video_id: 0,
				initTime: 0,  // 视频播放初始位置
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			this.videoContext = uni.createVideoContext('videoId', this);
			this.video_id = options.video_id;
			this.initTime = options.initTime;
			this.videoUrl = global.videoUrl;
			// this.videoContext.requestFullScreen({
			// 	direction: 90
			// }); //direction: 90  这个是控制全屏的时候视屏旋转多少度
			this.videoContext.play();
			this.videoplay = true; // 显示播放盒子
		},
		onUnload() {
			this.saveTime();
		},
		onReady() {},
		onShow() {},
		onPullDownRefresh() {},
		onReachBottom(e) {},
		onPageScroll(e) {},
		methods: {
			back() {
				uni.navigateBack()
			},
			videoPause() {
				
			},
			videoEnd() {
				// this.saveTime();
				uni.navigateBack()
			},
			videoError() {
				this.$message.info('视频播放失败,请重试');
			},
			timeupdate(e) {
				this.videoTime = parseInt(e.detail.currentTime);
			},
			saveTime() {
				this.$api.post(global.apiUrls.post6554c06c81475, {
					accompanylist_id: this.video_id,
					schedule: this.videoTime
				}).then(res => {
					console.log(res);
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.platformMessage_fd0_0_c0_c0 {
		font-size: 25rpx;
		color: #fff;
		position: absolute;
		top: 25rpx;
		left: 25rpx;
		z-index: 10;
	}
	video {
		height: 100vh;
		width: 100vw;
	}

	page {
		background: rgba(0, 0, 0, 0.3);
	}
</style>